var mydialog;
var base_name;
$(function(){
	base_name=$("#base_alter_name").html();
});

function cu_exter_add(){
	var store_id=$("#store_id").val();
	var store_name=$("#store_name").val();
	var store_unified=$("#store_unified").val();
	var store_tel=$("#store_tel").val();
	var store_add=$("#store_add").val();
	
	if(store_id==''){
		alert(base_name+'不能為空');
		return;
	}
	
	$.ajax({
		url:'cu_store',
		type:'post',
		data:{operator:'31',type:2,store_id:store_id,store_name:store_name,store_unified:store_unified,store_tel:store_tel,store_add:store_tel},
		dataType:'json',
		success:cu_attach_add_status,
		error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
	});
}

function cu_attach_add_status(data){
	if(data.status===1){
		location.reload();
	}
}

function cu_exter_alter(id){
	var data=$("#"+id).html();
	art.dialog({
		title:base_name+'-修改',
		content:data,
		lock:true
	});
}

function cu_exter_del(id){
	if(confirm('您確定刪除嗎?')){
		mydialog=art.dialog({title:'請稍候...',lock:true});
		$.ajax({
			url:'cu_store',
			type:'post',
			dataType:'json',
			data:{operator:'31',type:4,id:id},
			success:cu_attach_del_status,
			error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus);}
		});
	}
}

function cu_attach_del_status(data){
	if(data.status===1){
		mydialog.content('刪除成功');
		location.reload();
	}
}